//
//  AddAndDelViewController.swift
//  CTCollectionViewDemo
//
//  Created by GodCoder on 2019/8/18.
//  Copyright © 2019 CTCollectionView. All rights reserved.
//

import UIKit

class AddAndDelViewController: UIViewController {

    @IBOutlet weak var bgView: UIView!
    lazy var itemSize = CGSize(width: self.bgView.frame.width/4*3, height: 180)
    
    lazy var collectionView: UICollectionView = {
        let layout = HeaderDragLayout.init()
        layout.scrollDirection = .vertical
        layout.itemSize = itemSize
        layout.minimumInteritemSpacing = 10
        layout.minimumLineSpacing = 10
        
        let cv = UICollectionView.init(frame: CGRect(x: 0, y: 0, width: bgView.frame.width, height: bgView.frame.height), collectionViewLayout: layout)
        cv.backgroundColor = UIColor.white
        cv.dataSource = self
        cv.delegate = self
        cv.register(UICollectionViewCell.self, forCellWithReuseIdentifier: "UICollectionViewCellID1")
        return cv
    }()
    let colors: [UIColor] = [UIColor.init(named: "Grey")!, UIColor.init(named: "LightOrange")!, UIColor.init(named: "LightRed")!, UIColor.init(named: "Primary")!]
    let images: [String] = ["3", "4", "5", "6", "7", "8", "9"]
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        bgView.addSubview(collectionView)
    }

}


extension AddAndDelViewController: UICollectionViewDataSource, UICollectionViewDelegate {

    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return 10
    }
    
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "UICollectionViewCellID1", for: indexPath)
        cell.backgroundColor = UIColor.init(named: "Grey")
        
        return cell
    }
}
